package com.itlaobing.core;

import javax.xml.namespace.QName;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;

public class EstablishingConnection {

    private static String name = EstablishingConnection.class.getName();
    private static Logger logger = Logger.getLogger(name);

    public static void main(String[] args) throws SQLException, ClassNotFoundException {

        String name = "Oracle" ;  //  MySQL |  Oracle

        String driverClassName =null;
        String url = null;
        String username = null;
        String password = null;

        name = name.toLowerCase();
        switch (name){
            case "mysql":
                driverClassName = "com.mysql.cj.jdbc.Driver";
                url = "jdbc:mysql://localhost:3306/itlaobing?serverTimezone=Asia/Shanghai";
                username = "root";
                password = "";
                break;
            case  "oracle":
                driverClassName = "oracle.jdbc.driver.OracleDriver" ;
                url = "jdbc:oracle:thin:@localhost:1521:T2081" ;
                username = "itlaobing" ;
                password = "itlaobing" ;
                break;
            default:
                System.exit(0);
        }
        Class.forName(driverClassName);
        Connection connection = DriverManager.getConnection(url,username,password);
        logger.info(String.valueOf(connection));

        connection.close();
    }
}
